#include "CSetStringAttributeCommand.h"
#include "CUserInterface.h"
#include "CLevelEditor.h"
#include "CSceneObject.h"
#include "IAttributes.h"

extern CGlobals* g;
extern CUserInterface* ui;
extern CLevelEditor* editor;

CSetStringAttributeCommand::CSetStringAttributeCommand (int id, stringc name, stringw newValue)
{
	m_id = id;
	m_name = name;
	m_oldValue = editor->getSceneObjectFromID(id)->m_UserData->getAttributeAsStringW(name.c_str());
	m_newValue = newValue;
	setDescription(stringw(L"change ") + name.c_str());
}

void CSetStringAttributeCommand::redo ()
{
	editor->getSceneObjectFromID(m_id)->m_UserData->setAttribute(m_name.c_str(), m_newValue.c_str());
}

void CSetStringAttributeCommand::undo ()
{
	editor->getSceneObjectFromID(m_id)->m_UserData->setAttribute(m_name.c_str(), m_oldValue.c_str());
}
